
#include "Creature.h"

#include "BasicCreature.h"
namespace jcrada {

    BasicCreature::BasicCreature(int hidden_layers, int neurons_per_layer ) :
    Creature( BODY_PARTS, CONSTRAINTS, hidden_layers, neurons_per_layer ) {
        setName("BasicCreature");
    }

    BasicCreature::~BasicCreature( ) {
    }

    void BasicCreature::set( const btTransform& at ) {
        getBodyPart(ROOT).setId(ROOT);
        getBodyPart(ROOT).setName("Root");
        getBodyPart(ROOT).setParentId(Creature::B_NONE);
        getBodyPart(ROOT).setShape(BodyPart::S_SPHERE);
        getBodyPart(ROOT).setSize(1.0, 1.0, 1.0);
        getBodyPart(ROOT).setMass(1.0);

        getBodyPart(LLEG).setId(LLEG);
        getBodyPart(LLEG).setName("LeftLeg");
        getBodyPart(LLEG).setParentId(ROOT);
        getBodyPart(LLEG).setShape(BodyPart::S_CAPSULE_Y);
        getBodyPart(LLEG).setSize(0.2, 2.0, 0.2);
        getBodyPart(LLEG).setMass(2.0);

        getBodyPart(RLEG).setId(RLEG);
        getBodyPart(RLEG).setName("RightLeg");
        getBodyPart(RLEG).setParentId(ROOT);
        getBodyPart(RLEG).setShape(BodyPart::S_CAPSULE_Y);
        getBodyPart(RLEG).setSize(0.2, 2.0, 0.2);
        getBodyPart(RLEG).setMass(2.0);

        for (int i=  0 ; i < CONSTRAINTS ;++i){
            getConstraint(i).setType(Constraint::CT_GENERIC_6DOF);
        }
        getConstraint(LHIP).setId(LHIP);
        getConstraint(LHIP).setType(Constraint::CT_CONE_TWIST);
        getConstraint(LHIP).setName("LeftHip");
        getConstraint(LHIP).setIdBodyA(getBodyPart(ROOT).getId());
        getConstraint(LHIP).setIdBodyB(getBodyPart(LLEG).getId());
        getConstraint(LHIP).setConnectionA(Constraint::SPHERE_R5_LEFT);
        getConstraint(LHIP).setConnectionB(Constraint::CYLINDER_TOP);
        getConstraint(LHIP).setLinearLowerUpperLimits(btVector3(0.0, 0.0, 0.0), btVector3(0.0, 0.0, 0.0));
        getConstraint(LHIP).setAngularLowerUpperLimits(btVector3(0.0, 0.0, 0.0), btVector3(M_PI_4, M_PI_4, M_PI_4));

        getConstraint(RHIP).setId(RHIP);
        getConstraint(RHIP).setType(Constraint::CT_CONE_TWIST);
        getConstraint(RHIP).setName("RightHip");
        getConstraint(RHIP).setIdBodyA(getBodyPart(ROOT).getId());
        getConstraint(RHIP).setIdBodyB(getBodyPart(RLEG).getId());
        getConstraint(RHIP).setConnectionA(Constraint::SPHERE_R5_RIGHT);
        getConstraint(RHIP).setConnectionB(Constraint::CYLINDER_TOP);
        getConstraint(RHIP).setLinearLowerUpperLimits(btVector3(0.0, 0.0, 0.0), btVector3(0.0, 0.0, 0.0));
        getConstraint(RHIP).setAngularLowerUpperLimits(btVector3(0.0, 0.0, 0.0), btVector3(M_PI_4, M_PI_4, M_PI_4));

        Creature::set(at);
    }

}
